package com.gmall.item.controller;

import com.gmall.common.result.Result;
import com.gmall.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/item")
public class ItemApiController {

     @Autowired
     private ItemService itemService;


    /**
     * 详情接口
     * /api/item/{skuId}
     * @param skuId
     * @return
     */
    @GetMapping("{skuId}")
    public Result<Map<String,Object>> getItem(@PathVariable Long skuId){

        /**
         * resultMap
         * key                value
         * skuInfo          Sku信息
         * categoryView     一级，二级，三级分类
         * skuImageList     Sku的图片列表
         * tm              品牌信息
         */
        Map<String,Object> resultMap=this.itemService.getItem(skuId);

        return Result.ok(resultMap);
    }
}
